// serviceDetail.js
var app = getApp();

Page({
  data: {
    apis: app.data.ipconfig,
    indicatorDots: true,
    autoplay: true,
    interval: 2000,
    duration: 500,
    circular: true,
    loading: '',
    markers: [],
    latitude: '',
    longitude: '',
    address: ''
  },

  onLoad: function () {
    var that = this;
 
    //查询轮播图片进行渲染显示
    wx.request({
      url: that.data.apis + '/wxxiaochengxu/homebannerApi/homebannerList',
      data: { appid: app.data.appid, openid: wx.getStorageSync('openid') },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        console.log(res);
        that.setData({
          swiperBanner: res.data.res.homebannerlist,
          loading: 'hidden'
        })
      },
      fail: function () {
        console.log("接口出现异常");
      }
    })
    //查询首页分类进行渲染显示
    wx.request({
      url: that.data.apis + '/wxxiaochengxu/homebannerApi/getmenus',
      data: { appid: app.data.appid, openid: wx.getStorageSync('openid') },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        that.setData({
          datalist: res.data.res
        })
      },
      fail: function () {
        console.log("接口出现异常");
      }
    })
    //查询今日首推进行渲染显示
    wx.request({
      url: that.data.apis + '/wxxiaochengxu/homebannerApi/getDevaluationList',
      data: { appid: app.data.appid, openid: wx.getStorageSync('openid') },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        //console.log(res.data.res)
        that.setData({
          todayShops: res.data.res
        })
      },
      fail: function () {
        console.log("接口出现异常");
      }
    })
  },
 
  //点击轮播图片进行跳转
  thisClick: function (e) {
    if (e.currentTarget.dataset.btype == 1) {
      console.log('跳转多商品');
      wx.navigateTo({
        url: '../../pages/more/index?flag=1&id=' + e.currentTarget.dataset.homebannerid + '&head=0&menusname='
      })
    } else if (e.currentTarget.dataset.btype == 2) {
      console.log('跳转单商品');
      wx.navigateTo({
        url: '../../pages/shopDetails/index?shopid=' + e.currentTarget.dataset.bcontent
      })
    } else if (e.currentTarget.dataset.btype == 3) {
      console.log('跳转宣传页');
      wx.navigateTo({
        url: '../../pages/publicity/index?flag=1&id=' + e.currentTarget.dataset.homebannerid
      })
    }
  }
  ,
   lookMoreComments: function () {
  
    wx.navigateTo({
      url: '../../pages/shopDetails/index?shopid=' + shopid
    })
  }

})